package com.tedu.ds.equipmentType.controller;

import com.tedu.ds.base.response.JsonResult;
import com.tedu.ds.equipmentType.pojo.dto.EquipmentTypeParam;
import com.tedu.ds.equipmentType.pojo.dto.EquipmentTypeQuery;
import com.tedu.ds.equipmentType.service.EquipmentTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/equipmentType")
@Api(tags = "设备类型模块")
public class EquipmentTypeController {
    @Autowired
    private EquipmentTypeService equipmentTypeService;

    @PostMapping("/select")
    @ApiOperation("查询功能")
    public JsonResult select(@RequestBody EquipmentTypeQuery equipmentTypeQuery){
        return JsonResult.ok(equipmentTypeService.select(equipmentTypeQuery));
    }

    @PostMapping("/save")
    @ApiOperation("新增和更新功能")
    public JsonResult save(@RequestBody EquipmentTypeParam equipmentTypeParam){
        equipmentTypeService.save(equipmentTypeParam);
        return JsonResult.ok();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除功能")
    @ApiImplicitParam(name = "id",value = "设备类型id",required = true)
    public JsonResult delete(@PathVariable Integer id){
        equipmentTypeService.delete(id);
        return JsonResult.ok();
    }

}
